ADD_SUBDIRECTORY (eti)
FILE(GLOB TCHEM_HDR "*.hpp"
                    "impl/*.hpp"
                    "problems/*.hpp"
                    "aerosol_impl/*.hpp"
)
FILE(GLOB TCHEM_SRC "*.cpp" "${CMAKE_CURRENT_BINARY_DIR}/eti/*.cpp")
#MESSAGE(STATUS "CURRENT BINARY DIR ${CMAKE_CURRENT_BINARY_DIR}")
#MESSAGE(STATUS "TCHEM_SRC ${TCHEM_SRC}")

ADD_LIBRARY(tchem STATIC ${TCHEM_SRC})
IF (TCHEM_ENABLE_SHARED_BUILD)
  SET_PROPERTY(TARGET tchem PROPERTY POSITION_INDEPENDENT_CODE ON)
ENDIF()

TARGET_LINK_LIBRARIES(tchem
  ${TCHEM_INTERNAL_KOKKOS_TARGET}
  ${TCHEM_INTERNAL_TINES_TARGET}
)

TARGET_INCLUDE_DIRECTORIES(tchem
  PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/impl>
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/problems>
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/aerosol_impl>
  $<INSTALL_INTERFACE:${TCHEM_INSTALL_INCLUDE_PATH}>
)

IF(TCHEM_ENABLE_INSTALL)
  INSTALL(TARGETS tchem
    EXPORT tchem-targets
    LIBRARY DESTINATION "${TCHEM_INSTALL_LIB_PATH}"
    ARCHIVE DESTINATION "${TCHEM_INSTALL_LIB_PATH}"
  )

  INSTALL(FILES ${TCHEM_HDR}
    DESTINATION "${TCHEM_INSTALL_INCLUDE_PATH}"
  )

  INSTALL(EXPORT tchem-targets
    DESTINATION "${TCHEM_INSTALL_LIB_PATH}/cmake/TChem"
    NAMESPACE TChem::
  )

  CONFIGURE_PACKAGE_CONFIG_FILE("../cmake/TChemConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/TChemConfig.cmake"
    INSTALL_DESTINATION "${TCHEM_INSTALL_LIB_PATH}/cmake/TChem"
  )

  INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/TChemConfig.cmake"
    DESTINATION "${TCHEM_INSTALL_LIB_PATH}/cmake/TChem"
  )
ENDIF()